#pragma once
#include <streams.h>
#define BUF_NUM 2
class CMiiAudPinIn : public CBaseInputPin,  public CCritSec
{
public:
  /*  CCritSec m_tLock;*/

	CMediaType m_tType;

public:
	CMiiAudPinIn(CBaseFilter *pFilter, HRESULT *phr);
	virtual ~CMiiAudPinIn();

public:
    HRESULT CheckMediaType(const CMediaType *pmt);
	HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);
	HRESULT CompleteConnect(IPin *pReceivePin);
	CMediaType *MediaType();

    HRESULT SetMediaType(const CMediaType *);
    HRESULT CheckConnect(IPin *);

public:
    STDMETHODIMP Receive(IMediaSample *pSample);
	STDMETHODIMP EndOfStream(void);
public:
	WAVEFORMATEX m_vInfo;
	char *m_pBuffer[BUF_NUM];
	char *m_pLargeBuffer;
	int m_nBufIndex;
protected:
	HANDLE m_lock[2];
	bool m_bCopy;
	int mOutMax;
	int m_Pos;
	int AudioCopy(short * pDest, short * pSrc, int length);
	int mTimeStamp;
	// [1, 441]
	int m_nSourcIndex;
};

